package com.veer.shop.controller.admin;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.veer.shop.annotation.ApiControllerLog;
import com.veer.shop.annotation.ApiSecured;
import com.veer.shop.config.ApiUrlConfig;
import com.veer.shop.param.AttributeSetParam;
import com.veer.shop.pojo.AttributeSet;
import com.veer.shop.pojo.ResponseData;
import com.veer.shop.service.impl.admin.AttributeSetServiceImpl;

/**
 * 商品属性集  控制器
 * 
 * @author WangBin
 * 2020年11月14日-下午5:52:04
 */
@RestController
public class AttributeSetController {
	
	@Autowired
	private AttributeSetServiceImpl attributeSetServiceImpl;
	
	/**
	 * 获取商品属性集列表
	 */
	@ApiSecured
	@ApiControllerLog(description = "获取商品属性集列表")
	@RequestMapping( path = ApiUrlConfig.API_PRODUCT_ATTRIBUTE_SET_LIST_URL, method = RequestMethod.GET)
	public ResponseData<?> getList(@RequestBody(required = false) AttributeSetParam param, @RequestParam(required = false, name = "page_no", defaultValue = "1")Integer pageNo, @RequestParam(required = false, name = "page_size", defaultValue = "20")Integer pageSize)
	{
		return attributeSetServiceImpl.getList(param, pageNo, pageSize);
	}
	
	/**
	 * 新增|更新商品属性集
	 */
	@ApiSecured
	@ApiControllerLog(description = "新增|更新商品属性集")
	@RequestMapping( path = ApiUrlConfig.API_PRODUCT_ATTRIBUTE_SET_UPDATE_URL, method = RequestMethod.POST)
	public ResponseData<?> update(@RequestBody AttributeSet attributeSet)
	{
		return attributeSetServiceImpl.update(attributeSet);
	}
	
	/**
	 * 删除商品属性集
	 */
	@ApiSecured
	@ApiControllerLog(description = "删除商品属性集")
	@RequestMapping( path = ApiUrlConfig.API_PRODUCT_ATTRIBUTE_SET_DELETE_URL, method = RequestMethod.POST)
	public ResponseData<?> delete(@RequestParam(name = "attribute_set_id", defaultValue = "") String attributeSetId)
	{
		return attributeSetServiceImpl.delete(attributeSetId);
	}
	
	/**
	 * 商品属性集详情
	 */
	@ApiSecured
	@ApiControllerLog(description = "商品属性集详情")
	@RequestMapping( path = ApiUrlConfig.API_PRODUCT_ATTRIBUTE_SET_GET_URL, method = RequestMethod.GET)
	public ResponseData<?> get(@RequestParam(name = "attribute_set_id", defaultValue = "")Integer attributeSetId)
	{
		return attributeSetServiceImpl.get(attributeSetId);
	}
}
